import {getMeta, Router,routes} from "./routes/index.jsx";
import store from "./store/index.js";
import {useEffect, useState} from "react";
import {useLocation, useNavigate} from "react-router-dom";
import beforeEach from "./routes/beforeEach.js";
import afterEach from "./routes/afterEach.js";

function App() {
    // console.log(import.meta.env);
    const [update, forceUpdate] = useState(0)
    store.subscribe(() => {
        forceUpdate(update + 1)
    })
    const location = useLocation();
    const navigate = useNavigate();
    useEffect(()=>{
        location.meta = getMeta(location.pathname,routes);
        beforeEach(location,navigate)
        return ()=>{
            afterEach(location,navigate)
        }
    },[location])
    return (
        <Router></Router>
    )
}

export default App
